#ifndef NEWSPAPER_H
#define NEWSPAPER_H

using namespace std;

#include <QMainWindow>
#include <QtGui>
#include <cmath>
#include  "histogram.h"

class NewspaperSegmentation : public QMainWindow{
	
	Q_OBJECT
	
	public:
		NewspaperSegmentation();
		~NewspaperSegmentation();
		int energy;
	
	private slots:
		void open();
		void print();
		void zoomIn();
		void zoomOut();
		void normalSize();
		void fitToWindow();
		void about();
		
		void computeStep0Image();
		void computeStep1Image();
		void computeStep2Image();
		double computeEnergy(int x, int y, int neighborhood);
		void computeStep3Image();
		void computeStep4Image();
		void computeStep5Image();
		
		void showHistogram();
		void enableDisableHistogramEqualization( bool );
		
	private:
		void createActions();
		void createMenus();
		void createToolBars();
		
		void updateActions();
		void scaleImage(double factor);
		void adjustScrollBar(QScrollBar *scrollBar, double factor);
		void deleteImages();
		void setCurrentImage( int );
		
		int getPixel( QImage*, int, int );
		
		QLabel *imageLabel;
		QScrollArea *scrollArea;
		double scaleFactor;
		
	#ifndef QT_NO_PRINTER
		QPrinter printer;
	#endif
		
		QImage* image_step[6];
		vector<float>* histogram[6];
		
		int current_image;
		
		QAction *openAct;
		QAction *printAct;
		QAction *exitAct;
		QAction *zoomInAct;
		QAction *zoomOutAct;
		QAction *normalSizeAct;
		QAction *fitToWindowAct;
		QAction *aboutAct;
		QAction *aboutQtAct;
		
		QAction *step0Act;
		QAction *step1Act;
		QAction *step2Act;
		QAction *step3Act;
		QAction *step4Act;
		QAction *step5Act;
		QAction *showHistogramAct;
		QAction *enableDisableHistogramEqualizationAct;

		QMenu *fileMenu;
		QMenu *viewMenu;
		QMenu *operationsMenu;
		QMenu *helpMenu;
		
		QToolBar *operationsToolBar;
		QToolBar *viewToolBar;
		
		Histogram *histogram_image;
		int k_max;
		float eta;
};

#endif
